class MembersController < ApplicationController

	layout 'standard'

	before_filter	:login_required
	before_filter	:admin_required
	before_filter :find_repository, :find_members

	def index
		@candidates = User.find(:all, :conditions => ["role!=?", User.ADMIN_ROLE]) - @members
	end

	def regenerate_membership
		# remove all
		@repository.clear_membership

		candidates = params[:selected_users].split(",")

		candidates.collect do |c|
			@repository.create_member(c)
		end

		@repository.update_svn_password

		render :text => 'Changes has applied.'
	end


	protected
		def find_members
			@members = @repository.members
		end
end
